/**
 * CCodeGenerator: StaticJavaLib.h
 * CIS 706 Robby
 * Team Project
 * Heqing Huang & Rui Zhuang
 */


#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>

#define bool int
#define true 1
#define false 0

//bool, TRUE(true), FALSE(false) are undefined in C
//no function override supported in C

//public static void assertTrue(final boolean b)
void StaticJavaLib_assertTrue(bool b)
{
	  assert(b);
}

//public static boolean getBooleanArgument(@NonNullElements final String[] args, final int i)
//add the length of the array as a parameter
bool StaticJavaLib_getBooleanArgument(char** args ,int length, int i)
{
	  //no way to get the size of the array
	 assert(args!=NULL && i>=0 && i<length);
	 if(!strcmp(args[i],"true"))
		 return true;
	 if(!strcmp(args[i],"false"))
		 return false;
}

//public static int getIntArgument(@NonNullElements final String[] args, final int i)
//add the length of the array as a parameter
int StaticJavaLib_getIntArgument(char** args,int length, int i)
{
	  //no way to get the size of the array
	 assert(args!=NULL && i>=0 && i<length);
	 return atoi(args[i]);
}

//public static void print(final int i)
void StaticJavaLib_printi(int i)
{
	  printf("%d",i);
}

//public static void print(final boolean b)
void StaticJavaLib_printb(bool i)
{
	if(i==0)
		printf("%s","false");
	else
		printf("%s","true");
}

//public static void println()
void StaticJavaLib_printlnn()
{
	  printf("\n");
}

//public static void println(final int i)
void StaticJavaLib_printlni(int i)
{
	  printf("%d\n",i);
}

//public static void println(final boolean b)
void StaticJavaLib_printlnb(bool i)
{
	if(i==0)
		printf("%s\n","false");
	else
		printf("%s\n","true");
}
